<?php
/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the LGPL. For more information, see
 * <http://www.doctrine-project.org>.
 */

require_once '../config.php';
$tool = new \Doctrine\ORM\Tools\SchemaTool($em);

//$cmf = $em->getClassMetadata('Entities');
$classes = "";
//  

//);
$cmf = $em->getMetadataFactory();
$cmf->getLoadedMetadata();

//$cache;
$i= 0;
$class = $cmf->getAllMetadata();


foreach ($class as $metadata) {
	
   	$prop = $metadata->rootEntityName;
    
//   	switch($prop){
//   		case "Entities\ProcedimentoExecutado":
//   		case "Entities\Estado":
//   		case "Entities\Cid":
   			
//   			continue;
//   		default:
	   	 	echo  "<br>" . $prop . "<br>";
		   	$classes[$i] = $em->getClassMetadata($prop);
//		   	$tool->updateSchema($classes);
			$i++;
   			
//   	}
   	
  
   	
   
   
}

try {
	$tool->updateSchema($classes);	
	$classes = "";
} catch (Exception $e) {
	echo $e->getMessage() . "<br />";
	print_r($e);
	
}




//print_r($class);
//
//$classes = array(
//  $em->getClassMetadata('Entities\Cidade'),
//  $em->getClassMetadata('Entities\Cliente'),
//  $em->getClassMetadata('Entities\Convenio'),
//  $em->getClassMetadata('Entities\Endereco'),
//  $em->getClassMetadata('Entities\EnderecoConvenio'),
//  $em->getClassMetadata('Entities\Estado'),
//  $em->getClassMetadata('Entities\PlanoConvenio'),
//  $em->getClassMetadata('Entities\ContatoConvenio'),
//  $em->getClassMetadata('Entities\Medico'),
//  $em->getClassMetadata('Entities\Especialidade'),
//  $em->getClassMetadata('Entities\TipoMedico'),
//  $em->getClassMetadata('Entities\TipoMedico'),
//  $em->getClassMetadata('Entities\TipoMedico'),
//  $em->getClassMetadata('Entities\TipoMedico'),
//  $em->getClassMetadata('Entities\EnderecoMedico')
//);
